package chapter02

object Test28_tuple {
  def main(args: Array[String]): Unit = {
    val tuple = ("abc", 200, true)
    //通过下标访问元素
    println(tuple._2)
    println(tuple._1)
    println(tuple.productElement(0))
    //循环遍历
    for(i<-tuple.productIterator){
      println(i)
    }
    //map中的键值对 其实就是一个元组
    val map = Map("a" -> 20, "b" -> 30, "c" -> 40)
    val map1 = Map(("a", 20), ("b", 30), ("c", 40))
    map.foreach(kv=>{println(kv._1)
      println(kv._2)})
    map.foreach(kv=>{println(kv)})
    List(Map("name"->"张三","语文"->80,"数学"->85,"英语"->70),
      Map("name"->"李四","语文"->80,"数学"->85,"英语"->70),
        Map("name"->"王五","语文"->80,"数学"->85,"英语"->70))
  }
}
